package com.chx.three.fxgood.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;

import com.chx.three.fxgood.utils.DensityUtil;

/**
 * 水平滑动的布局
 */
public class SelectHorizontalScrollView extends HorizontalScrollView {
    private Context context;
    private OnScrollChangedListener onScrollChangedListener;
    private LinearLayout linearLayout;

    public SelectHorizontalScrollView(Context context) {
        this(context, null);
    }

    public SelectHorizontalScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SelectHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context=context;
        linearLayout = new LinearLayout(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        linearLayout.setLayoutParams(params);
        addView(linearLayout);
    }
    public LinearLayout getLayout(){
        return this.linearLayout;
    }
    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        if(onScrollChangedListener!=null){
            onScrollChangedListener.onScrollChanged(l,t,oldl,oldt);
        }
        super.onScrollChanged(l, t, oldl, oldt);
    }
    public void setOnScrollChangedListener(OnScrollChangedListener onScrollChangedListener){
        this.onScrollChangedListener=onScrollChangedListener;
    }



    public interface OnScrollChangedListener {
        void onScrollChanged(int l, int t, int oldl, int oldt);
    }
}
